﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace zDit.Core
{
    public class JsonPagedList<T>
    {
        public int PageIndex
        {
            get { return PagedList.PageIndex; }
        }
        public int PageSize
        {
            get { return PagedList.PageSize; }
        }
        public int TotalCount
        {
            get { return PagedList.TotalCount; }
        }
        public int TotalPages
        {
            get { return PagedList.TotalPages; }
        }
        //public bool HasPreviousPage { get; protected set; }
        //public bool HasNextPage { get; protected set; }
        public PagedList<T> PagedList { get; protected set; }
        public JsonPagedList(IList<T> source, int pageIndex, int pageSize)
        {
            this.PagedList = new PagedList<T>(source, pageIndex, pageSize);
        }
        public JsonPagedList(IQueryable<T> source, int pageIndex, int pageSize)
        {
            this.PagedList = new PagedList<T>(source, pageIndex, pageSize);
        }
        public  JsonPagedList(IEnumerable<T> source, int pageIndex, int pageSize)
        {
            this.PagedList = new PagedList<T>(source, pageIndex, pageSize, source.Count());
        }
        public JsonPagedList(IEnumerable<T> source, int pageIndex, int pageSize, int totalCount)
        {
            this.PagedList = new PagedList<T>(source, pageIndex, pageSize, totalCount);
        }
        //public static JsonPagedList<T> Create(IList<T> pagedList, int pageIndex, int pageSize)
        //{
        //    return new JsonPagedList<T>(pagedList, pageIndex, pageSize);
        //}
    }
}
